package com.higgins.server.agentapp.datamodel;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;
import com.higgins.client.agentapp.datamodel.AgentDTO;
import com.higgins.client.agentapp.datamodel.JobSiteDTO;
import com.higgins.client.dataModel.CoveringLetterDTO;
import com.higgins.client.dataModel.StrategyDTO;
import com.higgins.server.agentapp.datamodel.Agency;

@Entity
@Table(name = "agent")
public class Agent {
    @Id
    @GeneratedValue(generator = "increment")
    @GenericGenerator(name = "increment", strategy = "increment")
    private Long id;
    
    private String name;

    @ManyToOne
    @JoinColumn(name="agencyId")
    private Agency agency;

    private String phone;
    private String email;
    private String comment;
    private Integer rank;
    
    
    public Agent() {
        // This is used by JPA
    }
 
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getEmail()	{
    	return email;
    }
    public void setEmail(String email)	{
    	this.email = email;
    }
    public String getComment()	{
    	return comment;
    }
    public void setComment(String comment)	{
    	this.comment = comment;
    }
    public Integer getRank()	{
    	return rank;
    }
    public void setRank(Integer rank)	{
    	this.rank = rank;
    }
    public Agency getAgency()	{
    	return agency;
    }
    public void setAgency(Agency agency)	{
    	this.agency = agency;
    }
    public AgentDTO toDTO()	{
    	AgentDTO dto = new AgentDTO();
    	dto.setId(id);
    	dto.setName(name);
    	dto.setPhone(phone);
    	dto.setEmail(email);
    	dto.setComment(comment);
    	dto.setRank(rank);
    	return dto;
    }
    public void update(AgentDTO dto)	{
    	this.name = dto.getName();
    	this.phone = dto.getPhone();
    	this.email = dto.getEmail();
    	this.comment = dto.getComment();
    	this.rank = dto.getRank();
    }
}